home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / terms / kermit / b / ckuins.doc < prev    next >
Encoding:
Text File  |  1993-08-09  |  63.1 KB  |  1,345 lines

  1. C-KERMIT 5A INSTALLATION INSTRUCTIONS FOR UNIX                       -*-text-*-
  2.  
  3.   5A(189)
  4.   Mon Aug  9 17:43:06 1993
  5.  
  6.   F. da Cruz, Columbia University
  7.  
  8.   Copyright (C) 1985, 1992, Trustees of Columbia University in the City of New
  9.   York.  Permission is granted to any individual or institution to use this
  10.   software as long as it is not sold for profit.  This copyright notice must be
  11.   retained.  This software may not be included in commercial products without
  12.   written permission of Columbia University.
  13.  
  14. DISCLAIMER:
  15.  
  16.   The C-Kermit software is provided in source code form by Kermit Development
  17.   and Distribution, Columbia University.  The software is provided "as is;" no
  18.   other warranty is provided, express or implied, including without
  19.   limitations, any implied warranty of merchantability or implied warranty of
  20.   fitness for a particular purpose.
  21.  
  22.   Neither Columbia University nor any of the contributors to the C-Kermit
  23.   development effort, including, but not limited to, AT&T, Digital Equipment
  24.   Corporation, Data General Corporation, or International Business Machines
  25.   Corporation, warrant C-Kermit software or documentation in any way.  In
  26.   addition, neither the authors of any Kermit programs, publications or
  27.   documentation, nor Columbia University nor any contributing institutions or
  28.   individuals acknowledge any liability resulting from program or
  29.   documentation errors.
  30.  
  31.  
  32. DOCUMENTATION
  33.  
  34. C-Kermit 5A is documented in the book "Using C-Kermit" by Frank da Cruz
  35. and Christine M. Gianone, Digital Press, Burlington, MA, USA.  Digital
  36. Press ISBN: 1-55558-108-0; Prentice-Hall ISBN: 0-13-037490-3.  Price: US
  37. $34.95.  In USA, call DECdirect at 1-800-344-4825, refer to order number
  38. EY-J896E-DP.
  39.  
  40.  
  41. OVERVIEW
  42.  
  43. This file contains UNIX-specific information.  For a description of general
  44. (system-independent) configuration options for C-Kermit, please read the file
  45. CKCCFG.DOC.  For information about known limitations or bugs, and possible
  46. workarounds, see the files CKCKER.BWR and CKUKER.BWR.
  47.  
  48. Once you have built C-Kermit according to the instructions in this file,
  49. you should install it in a directory that is in the users' PATH, but that
  50. is not likely to be overwritten when you install a new version of the
  51. operating system.  A good candidate would be the /usr/local/bin/ directory.
  52.  
  53. You should also install the man page, which is called ckuker.nr, in the
  54. man page directory for local commands, such as /usr/man/manl/, renamed
  55. appropriately, e.g. to kermit.l.
  56.  
  57. It might also be a good idea to make a "Kermit library" directory for sample
  58. files and non-man-page-style documentation.  /usr/local/lib/kermit/ might be
  59. a good place for this.  Some of the files that could go there are:
  60.  
  61. ckermit.ini
  62.   The standard initialization file.  Users should copy this to
  63.   their home directories and rename it to .kermrc.  There is no provision
  64.   in UNIX C-Kermit for a system-wide intitialization file (but see below).
  65.  
  66. ckermod.ini
  67.   A sample customization file.  Users should copy this file to
  68.   their home directories, make any desired modifications (user- or
  69.   site-specific customizations), and rename it to .mykermrc.
  70.  
  71. ckermit.kdd
  72.   A sample dialing directory file.
  73.  
  74. ckermit.ksd
  75.   A sample services directory.
  76.  
  77. ckedemo.ini
  78.   Macro definitions from "Using C-Kermit".
  79.  
  80. ckevt.ini
  81.   Command file to demonstrate special screen effects from "Using C-Kermit"
  82.  
  83. ckcker.upd
  84.   A file listing the updates, changes, and corrections made to C-Kermit since
  85.   publication of "Using C-Kermit".
  86.  
  87. ckcker.bwr
  88.   The general C-Kermit beware file.
  89.  
  90. ckuker.bwr
  91.   The UNIX-specific C-Kermit beware file.
  92.  
  93.  
  94. Here is one method, suggested by Wayne Hauber and John Hascall of Iowa State
  95. University, of installing a single system-wide C-Kermit initialization file:
  96.  
  97. "Rather than copy individual versions of .kermrc, we created a shell script
  98. that looks like:
  99.  
  100. #!/bin/sh
  101. [ ! -f $HOME/.kermrc ] && {
  102.       echo "Setting up kermit configuration file..."
  103.       ln -s /usr/local/lib/.kermrc $HOME/.kermrc
  104. }
  105. exec /usr/local/bin/kermit.real $*
  106.  
  107. We named this thing kermit and called the kermit executable kermit.real."
  108.  
  109.  
  110. BUILDING C-KERMIT FOR UNIX
  111.  
  112. UNIX C-Kermit is built using the "make" utility, which contains the rules for
  113. building the program for each of the dozens of different kinds of UNIX systems
  114. that C-Kermit attempts to support.  "make" is driven by a file called
  115. "makefile", which is normally distributed as ckuker.mak.  You must rename this
  116. file to makefile before you can build the program:
  117.  
  118.   mv ckuker.mak makefile
  119.  
  120. and then you type "make xxx", where xxx is the system you want to build
  121. C-Kermit for.  These are listed in the comments at the top of the makefile.
  122. For example, to build C-Kermit for Berkeley UNIX 4.2, type:
  123.  
  124.   make bsd
  125.  
  126. Also check to see if there are comments about your particular version in its
  127. makefile entry itself.  Search for the make entry name followed by colon (e.g.
  128. "bsd:").
  129.  
  130. To add compilation options (which are explained later in this document) to
  131. your makefile entry without editing the makefile, include "KFLAGS=..." on the
  132. make command line, for example:
  133.  
  134.   make bsd KFLAGS=-DNODEBUG
  135.   make bsd "KFLAGS=-DKANJI -DNODEBUG -DNOTLOG -DDYNAMIC -UTCPSOCKET"
  136.  
  137. Quotes are necessary if the KFLAGS= clause includes spaces.  The KFLAGS are
  138. added to the end of the CFLAGS that are defined in the selected makefile
  139. entry.  For example, the "bsd" entry includes -DBSD4 -DTCPSOCKET, so the second
  140. example above compiles Kermit with the following options:
  141.  
  142.   -DBSD4 -DTCPSOCKET -DKANJI -DNODEBUG -DNOTLOG -DDYNAMIC -UTCPSOCKET
  143.  
  144. (Notice how "-UTCPSOCKET" is used to negate the effect of the "-DTCPSOCKET"
  145. option that is included in the makefile entry.)
  146.  
  147. WARNING: Be careful with KFLAGS.  If you build C-Kermit, change a couple
  148. files, and then run make again using the same make entry but specifying
  149. different KFLAGS than last time, make won't detect it and you could easily
  150. wind up with inconsistent object modules, e.g. some of them built with a
  151. certain option, others not.  When in doubt, "make clean" first to make sure
  152. all your object files are consistent.  Similarly, if you change CFLAGS, LIBS,
  153. or any other items in the makefile, or you rebuild using a different makefile
  154. entry, "make clean" first.
  155.  
  156. After you have built and tested the C-Kermit program successfully, you can
  157. discard the object (ck*.o) files, which are no longer needed.  Use "make
  158. clean" to do this.  If you don't need the source files (ck[cuw]*.[cwh]), you
  159. can remove them too.  Then move the wermit program to the desired location
  160. and rename it to "kermit", for example:
  161.  
  162.   mv wermit /usr/local/bin/kermit
  163.   chmod 775 /usr/local/bin/kermit
  164.  
  165. This file gives some supplementary information, primarily intended for when
  166. none of the built-in makefile entries results in a satisfactorily working
  167. Kermit for your UNIX system.
  168.  
  169.  
  170. UNIX MAKEFILE
  171.  
  172. The makefile is quite long, and at least two versions of UNIX, SCO Xenix/286
  173. and 2.x BSD, cannot cope with its length.  An attempt to "make sco286" gives
  174. the message "Make: Cannot alloc mem for env..  Stop".  Solution: edit away
  175. some or all of the nonrelevant material from the makefile.   (A separate
  176. version of the makefile is provided for BSD 2.x: ckubs2.mak.)
  177.  
  178. Some make programs reportedly cannot handle continued lines (lines ending
  179. in backslash (\).  If you have a problem with the makefile, try editing the
  180. makefile to join the continued lines (remove the backslashes and the following
  181. linefeed).
  182.  
  183. Other makefile troubles may occur because tabs in the makefile have somehow
  184. been converted to spaces.  Spaces and tabs are distinct in makefiles.
  185.  
  186. If the makefile entry for your version of C-Kermit does not include -DDYNAMIC,
  187. try adding it.  This should make the program image smaller, and it will
  188. allow you to use much longer packets and bigger window sizes.  If this works
  189. on your system, please notify the author at the address above.
  190.  
  191. If the makefile entry for your version of C-Kermit does not include TCP/IP
  192. support, but your UNIX system does support TCP/IP using the Berkeley sockets
  193. library, or some variation of it, try adding -DTCPSOCKET to your makefile
  194. entry.  If it "almost works", there are some other switches you can add to
  195. force recognition of the various slightly-incompatible TCP/IP implementations
  196. (-DWOLLONGONG, -DEXCELAN, -DINTERLAN, etc).
  197.  
  198.  
  199. BUILDING C-KERMIT FOR UNIX FROM MS-DOS DISTRIBUTION DISKETTES
  200.  
  201. If you have received C-Kermit on MS-DOS format diskettes (such as those
  202. distributed by Columbia), you should make sure that your DOS-to-UNIX
  203. conversion utility (such as "dosread") both: (1) changes line terminators in
  204. all files from carriage-return linefeed (CRLF) to just linefeed (LF) (such as
  205. "dosread -a") and remove any Ctrl-Z's, and (2) that all filenames are
  206. converted from uppercase to lowercase.  If these conversions were not done,
  207. you can use the following shell script on your UNIX system to do them:
  208. ---(cut here)---
  209. #!/bin/sh
  210. #
  211. # Shell script to convert C-Kermit DOS-format files into UNIX format.
  212. # Lowercases the filenames, strips out carriage returns and Ctrl-Z's.
  213. #
  214. x=$1    # the name of the source directory
  215. y=$2    # the name of the target directory
  216. if [ $# -lt 2 ]; then
  217.   echo "usage: $0 source-directory target-directory"
  218.   exit 1
  219. fi
  220. if cd $1 ; then
  221.   echo "Converting files from $1 to $2"
  222. else
  223.   echo "$0: cannot cd to $1"
  224.   exit 1
  225. fi
  226. for i in *; do
  227.   j=`echo $i | tr 'A-Z' 'a-z'`
  228.   echo $x/$i =\> $y/$j
  229.   tr -d '\015\032' < $i > $y/$j
  230. done
  231. ---(cut here)---
  232. Cut out this shell script, save it as "convert.sh" (or any other name you
  233. prefer), then "chmod +x convert.sh".  Then, create a new, empty directory
  234. to put the converted files in, and then "convert.sh /xxx /yyy" where /xxx
  235. is the name of the directory where the PC-format files are, and /yyy is the
  236. name of the new, empty directory.  The converted files will appear in the
  237. new directory.
  238.  
  239.  
  240. CHECKING THE RESULTS
  241.  
  242. Here are several quick checks you can run to tell whether your version of
  243. C-Kermit was built correctly for your UNIX system.
  244.  
  245.  0. Start C-Kermit (usually by typing "./wermit" in the directory where you ran
  246.     the makefile.  Do you see the C-Kermit> prompt?  If not, C-Kermit
  247.     incorrectly deduced that it was running in the background.  The test is in
  248.     conbgt() in ckutio.c.  If you can fix it for your system, please send in
  249.     the fix (Hint: read about "PID_T" below).  Otherwise, you can force
  250.     C-Kermit to foreground mode by starting it with the -z command line option,
  251.     as in "kermit -z", or giving the interactive command SET BACKGROUND OFF.
  252.  
  253.  1. When you type characters at the C-Kermit prompt, do they echo immediately?
  254.     If not, something is wrong with concb() and probably the other terminal
  255.     mode settings routines in ckutio.c.  Be sure you have used the most
  256.     appropriate make entry.
  257.  
  258.  2. At the C-Kermit> prompt, type "send *?".  C-Kermit should list all the
  259.     files in the current directory.  If not, it was built for the wrong type of
  260.     UNIX file system.  Details below.  In the meantime, try SET
  261.     WILDCARD-EXPANSION SHELL as a workaround.
  262.  
  263.  3. Create a file with a long name in your current directory, e.g.:
  264.  
  265.     % touch thisisafilewithaveryveryveryveryveryveryveryverylooooooooongname
  266.  
  267.     Check with ls to see if your version of UNIX truncated the name.  Now start
  268.     C-Kermit and type "send thisis<ESC>".  Does Kermit complete the name,
  269.     showing the same name as ls did?  If not, wrong filesystem.  Read on.
  270.  
  271.  4. Type Ctrl-C (or whatever your UNIX interrupt character is) at the prompt.
  272.     Do you get "^C..." and a new prompt?  If instead, you get a core dump,
  273.     "rm core" and then rebuild with -DNOCCTRAP added to your CFLAGS.
  274.  
  275.  5. Type Ctrl-Z (or whatever your UNIX suspend character is) to put C-Kermit in
  276.     the background.  Did it work?  If nothing happened, then (a) your version
  277.     of UNIX does not support job control, or (b) your version of C-Kermit was
  278.     probably built with -DNOJC.  If your session became totally frozen, then
  279.     your are probably running C-Kermit on a UNIX version that supports job
  280.     control, but under a shell that doesn't.  If that's not the case, look in
  281.     the psuspend() routine in ckutio.c and see if you can figure out what's
  282.     wrong.  If you can't, rebuild with -DNOJC>
  283.  
  284.  6. Try dialing out: SET MODEM <whatever>, SET LINE <whatever>, SET SPEED
  285.     <whatever>, DIAL <phone-number>.  If it doesn't work, keep reading.
  286.     After dialing, can you REDIAL?
  287.  
  288.  7. If your version was built with TCP/IP network support, try the SET HOST
  289.     command.
  290.  
  291.  8. Transfer some files in remote mode on incoming asynchronous serial (direct
  292.     or modem) connections, and on incoming network (telnet, rlogin, terminal
  293.     server) connections.
  294.  
  295.  9. Establish a serial connection from C-Kermit to another computer (direct
  296.     or dialed) and transfer some files.  If you have network support, do the
  297.     same with a network connection.
  298.  
  299. 10. If your version was built with fullscreen file transfer display support,
  300.     check that it works during local-mode file transfer.  Also, check
  301.     C-Kermit's operation afterwards: is the echoing funny?  etc etc.
  302.  
  303. 11. If your version was built with script programming language support,
  304.     TAKE the cketest.ini file to give it a workout.
  305.  
  306. 12. Does C-Kermit interlock correctly with UUCP-family programs (cu, tip,
  307.     uucp, etc)?  If not, read on.
  308.  
  309.  
  310. REDUCING THE SIZE OF THE EXECUTABLE PROGRAM IMAGE
  311.  
  312. 1. Many of C-Kermit's options and features can be deselected at compile time.
  313.    The greatest savings at the least sacrifice in functionality is to disable
  314.    the logging of debug information by defining NODEBUG during compilation.
  315.    See ckccfg.doc for further information.
  316.  
  317. 2. Most UNIX systems have a "strip" command to remove symbol table information
  318.    from an executable program image.  "man strip" for further information.
  319.    The same effect can be achieved by including "-s" among the link flags when
  320.    building C-Kermit.
  321.  
  322. 3. SCO, Interactive, and some other UNIX versions have an "mcs" command.
  323.    "mcs -d wermit" can be used to delete the contents of the ".comment"
  324.    section from the executable program image.
  325.  
  326.  
  327. THE FULLSCREEN FILE TRANSFER DISPLAY
  328.  
  329. For fullscreen file transfer display support, add -DCK_CURSES to your makefile
  330. entry (if necessary; many entries already have it, generally the ones ending
  331. in "c", for example "make sunos41c").  The screen handling is accomplished in
  332. UNIX using the curses library.  If you are creating a new makefile entry to
  333. include the fullscreen display, you must add one of the following to your UNIX
  334. makefile entry (whatever works):
  335.  
  336.   "LIBS= -lcurses -ltermcap"
  337.   "LIBS= -lcurses -ltermlib"
  338.   "LIBS= -lcurses"
  339.   "LIBS= -ltermlib"
  340.  
  341. to pull in the required libraries.  "man curses" for further information, and
  342. search through the makefile for "CK_CURSES" to see many examples.
  343.  
  344. In System V, there might be a complication.  Apparently System V curses (or at
  345. least some implementations of it) reserve the right to alter the buffering on
  346. the output file without restoring it afterwards, which can leave Kermit's
  347. command processing in a mess when the prompt comes back after a fullscreen
  348. file transfer display.  If you experience problems such as these, try adding
  349.  
  350.   -DCK_NEWTERM
  351.  
  352. to your makefile entry (see comments in screenc() in ckuusx.c for an
  353. explanation).
  354.  
  355. In SCO Xenix and SCO UNIX, there are two separate curses libraries, one based
  356. on termcap and the other based on terminfo.  The default library, usually
  357. terminfo, is established when the development system is installed.  To
  358. manually select terminfo (at compile time):
  359.  
  360.   compile -DM_TERMINFO and link -ltinfo
  361.  
  362. and to manually select termcap:
  363.  
  364.   compile -DM_TERMCAP and link -ltcap -ltermlib
  365.  
  366. <curses.h> looks at M_TERMINFO and M_TERMCAP to decide which header files to
  367. use.  /usr/lib/libcurses.a is a link to either libtinfo.a or libtcap.a.  The
  368. C-Kermit compilation options must agree with the version of the curses library
  369. that is actually installed.
  370.  
  371. NOTE: If you are doing an ANSI-C compilation and you get compile time warnings
  372. like the following:
  373.  
  374.   Warning: function not declared in ckuusx.c: wmove, printw, wclrtoeol,
  375.   wclear, wrefresh, endwin, etc...
  376.  
  377. it means that your <curses.h> file does not contain prototypes for these
  378. functions.  The warnings are harmless.
  379.  
  380. C-Kermit maintains a buffer to hold your termcap entry.  The size of this
  381. buffer is 1024.  Reportedly, some termcap entries might be longer than this.
  382. To allow for longer termcap entries, add a definition of TRMBUFL to your
  383. compilation CFLAGS, for example:
  384.  
  385.   -DTRMBUFL=2048
  386.  
  387. UNIX VERSIONS
  388.  
  389. There are several major varieties of UNIX: Bell Laboratories Seventh Edition,
  390. AT&T System V, Berkeley Standard Distribution (BSD), and POSIX.  Each has
  391. many, many subvarieties and descendents, and there are also hybrids that
  392. exhibit symptoms of two or more varieties, plus special quirks of their own.
  393.  
  394. Seventh edition versions of C-Kermit include the compile-time option -DV7 in
  395. the CFLAGS string in the makefile entry.  Various V7-based implementations are
  396. also supported: -DCOHERENT, -DMINIX, etc.
  397.  
  398. AT&T-based versions of UNIX Kermit include the compile-time option -DATTSV
  399. (standing for AT&T UNIX System V).  This applies to System III and to System V
  400. up to and including Release 2.  For System V Release 3, the flag -DSVR3 should
  401. be used instead (which also implies -DATTSV).  This is because the data type
  402. of signal() and several other functions was changed between SVR2 and SVR3.
  403. For System V Release 4, include -DSVR4 because of changes in uucp lockfile
  404. conventions; this also implies -DSVR3 and -DATTSV.
  405.  
  406. For BSD, the flag -BSDxx must be included, where xx is the BSD version
  407. number, for example BSD4 (for version 4.2 or later, using only 4.2 features),
  408. -DBSD41 (for BSD 4.1 only), -DBSD43 (for 4.3 or later), -DBSD29 (BSD 2.9
  409. for DEC PDP-11s).
  410.  
  411. For POSIX, include the flag -DPOSIX.  POSIX defines a whole new set of
  412. terminal i/o functions that are not found in traditional AT&T or Berkeley
  413. implementations, and also defines the symbol _POSIX_SOURCE, which is used
  414. in many system and library header files, mainly to disable non-POSIX features.
  415.  
  416. There is a tendency for UNIX implementations to be neither pure AT&T nor pure
  417. BSD nor pure POSIX, but a mixture of two or more of these, with "compatibility
  418. features" allowing different varieties of programs to be built on the same
  419. computer.  In general, Kermit tries not to mix & match but to keep a
  420. consistent repertoire throughout.  However, there are certain UNIX
  421. implementations that only work when you mix and match.  For example, the
  422. Silicon Graphics Iris workstation IRIX operating system (prior to version 3.3)
  423. is an AT&T UNIX but with a BSD file system.  The only way you can build Kermit
  424. successfully for this configuration is to include -DSVR3 plus the special
  425. option -DLONGFN, meaning "pretend I was built with -DBSDxx when it's time to
  426. compile directory-related code".  See the "iris" makefile entry.
  427.  
  428. STANDARDS
  429.  
  430. In edits 166-167, C-Kermit was heavily modified to try to keep abreast of new
  431. standards while still remaining compatible with old versions of C and UNIX.
  432. There are two new standards of interest: ANSI C (as described in Kernighan and
  433. Ritchie, "The C Programming Language", Second Edition, Prentice Hall, 1988)
  434. and POSIX.1 (IEEE Standard 1003.1 and ISO/IEC 9945-1, 1990, "Portable
  435. Operating System Interface").  These two standards have nothing to do with
  436. each other: you can build C-Kermit with a non-ANSI compiler for a POSIX
  437. system, or for a non-POSIX system with with an ANSI compiler.
  438.  
  439. (a) POSIX
  440.  
  441. POSIX.1 defines a repertoire of system functions and header files for use by C
  442. language programs.  Most notably, the ioctl() function is not allowed in
  443. POSIX; all ioctl() functions have been replaced by device-specific functions
  444. like tcsetattr(), tcsendbreak(), etc.
  445.  
  446. Computer systems (UNIX, and reportedly also forthcoming versions of VAX/VMS)
  447. that claim some degree of POSIX compliance have made some attempt to put their
  448. header files in the right places and give them the right names, and to provide
  449. system library functions with the right names and calling conventions.  Within
  450. the header files, POSIX-compliant functions are supposed to be within #ifdef
  451. _POSIX_SOURCE..#endif conditionals, and non-POSIX items are not within these
  452. conditionals.
  453.  
  454. If C-Kermit is built with the -DPOSIX flag, it attempts to configure itself
  455. for a pure POSIX environment.  It defines _POSIX_SOURCE, it calls only
  456. POSIX-defined functions, and it includes POSIX-defined header files.
  457.  
  458. If Kermit is built with _D_POSIX_SOURCE but not -DPOSIX, C-Kermit must be
  459. built with one of the -DBSD or -DATTSV flags (or one that implies them), but
  460. still uses only the POSIX features in the system header files.  This allows
  461. C-Kermit to be built on BSD or AT&T systems that have some degree of POSIX
  462. compliance, but still use BSD or AT&T specific features.
  463.  
  464. If Kermit is built with neither _D_POSIX_SOURCE nor -DPOSIX, the functions and
  465. header files of the selected version of UNIX (or VMS, etc) are used according
  466. to the CFLAGS Kermit was built with.
  467.  
  468. The POSIX standard does not define anything about uucp lockfiles.  "make
  469. posix" uses NO (repeat, NO) lockfile conventions.  If your POSIX-compliant
  470. UNIX version uses a lockfile convention such as HDBUUCP (see below), use
  471. the "posix" entry, but include the appropriate lockfile option in your KFLAGS
  472. on the "make" command line, for example:
  473.  
  474.    make posix "KFLAGS=-DHDBUUCP"
  475.  
  476. POSIX.1 also lacks certain other features that Kermit needs.  For example:
  477.  
  478.  - There is no defined way for an application to do wildcard matching of
  479.    filenames.  Kermit uses the inode in the directory structure, but POSIX
  480.    does not include this concept.  POSIX.2 will include functions for this,
  481.    named (I think) glob() and fnmatch(), but these functions are not yet in
  482.    Kermit.
  483.  
  484.  - There is no POSIX mechanism for dealing with modem signals, nor to enable
  485.    RTS/CTS or other hardware flow control.
  486.  
  487.  - There is no way to check if characters are waiting in a communications
  488.    device input buffer, short of trying to read them.
  489.  
  490.  - No way to do a millisecond sleep (no nap(), usleep(), select(), etc).
  491.  
  492.  - There is no popen().
  493.  
  494. So at this point, there cannot be one single fully functional POSIX form of
  495. C-Kermit unless it also has "extensions".
  496.  
  497. (b) ANSI C
  498.  
  499. The major difference between ANSI C and earlier C compilers is function
  500. prototyping.  ANSI C allows function arguments to be checked for type
  501. agreement, and (when possible) type coercion in the event of a mismatch.  For
  502. this to work, functions and their arguments must be declared before they are
  503. called.  The form for function declarations is different in ANSI C and
  504. non-ANSI C (ANSI C also accepts the earlier form, but then does not do type
  505. checking).
  506.  
  507. As of edit 167, C-Kermit tries to take full advantage of ANSI C features,
  508. especially function prototyping.  This removes many bugs introduced by
  509. differing data types used or returned by the same functions on different
  510. computers.  ANSI C features are automatically enabled when the symbol __STDC__
  511. is defined.  Most ANSI C compilers, such as GNU CC and the new DEC C compiler
  512. define this symbol internally.
  513.  
  514. To force use of ANSI C prototypes, include -DCK_ANSIC on the cc command line.
  515. To disable the use of ANSI prototypes, include -DNOANSI.
  516.  
  517. UNIX MAKE FAILURES
  518.  
  519. First, be sure the source files are stored on your current disk and directory
  520. with the right names (in lowercase).  Second, make sure that the makefile
  521. itself does not contain any lines with leading spaces: indented lines must all
  522. start with horizontal TAB, and no spaces.
  523.  
  524. Then make sure that your UNIX PATH is defined to find the appropriate compiler
  525. for your makefile entry.  For example, on SunOS systems, "make sunos41" builds
  526. C-Kermit for the BSD environment, and assumes that /usr/ucb/cc will be used
  527. for compilation and linking.  If your PATH has /usr/5bin ahead of /usr/ucb,
  528. you can have problems at compile or link time (a commonly reported symptom is
  529. the inability to fine "ftime" during linking).  Fix such problems by
  530. redefining your UNIX PATH, or by specifying the appropriate "cc" in CC=
  531. and CC2= statements in your makefile entry.
  532.  
  533. During edits 166-167, considerable effort went into making C-Kermit compilable
  534. by ANSI C compilers.  This includes prototyping all of C-Kermit's functions,
  535. and including the ANSI-defined system header files for system and library
  536. functions, as defined in K & R, second edition: <string.h>, <stdlib.h>,
  537. <unistd.h> (except on the NeXT this is <libc.h>), and <sys/stdtypes.h>.  If
  538. you get warnings about any of these header files not being found, or about
  539. argument mismatches involving pid_t, uid_t, or gid_t, look in ckcdeb.h and
  540. make amendments.  C-Kermit assumes it is being compiled by an ANSI-compliant C
  541. compiler if __STDC__ is defined, normally defined by the compiler itself.  You
  542. can force ANSI compilation without defining __STDC__ (which some compilers
  543. won't let you define) by including -DCK_ANSIC on the cc command line.
  544.  
  545. On the other hand, if your compiler defines __STDC__ but still complains about
  546. the syntax of Kermit's function prototypes, you can disable the ANSI-style
  547. function prototyping by including -DNOANSI on the command line.
  548.  
  549. For SCO UNIX, ODT, and XENIX compilations, be sure to pick the most
  550. appropriate makefile entry, and be sure you have installed an SCO development
  551. system that is keyed to your exact SCO operating system release, down to the
  552. minor version (like 2.3.1).
  553.  
  554. There seems to be a lot of controversy about whether to use the SCO Shared
  555. Libraries (lc_s), especially when building C-Kermit with curses or network
  556. support.  One user claims that an executable built under one version of SCO
  557. UNIX (say 3.2.2) will not run correctly on another version (say 3.2.4).
  558.  
  559. More on SCO: In version 3.2.2 the order in which libc and libx are searched is
  560. important for the directory-reading routines (opendir).  When using <ndir.h>,
  561. libx must be searched before libc (-lx -lc).  In version 3.2.4, <dirent.h>
  562. and libc should be used.  One user recommends the following for 3.2.2:
  563.  
  564.     -lx
  565.     -lx -lsocket        (net version)
  566.  
  567. and for 3.2.4:
  568.  
  569.     -lc -lx
  570.     -lc -lx -lsocket    (net version)
  571.  
  572. If you have problems at link or run time with a SCO 3.2.x version of C-Kermit,
  573. try juggling these items in the makefile entry.
  574.  
  575. If your compiler uses something other than int for the pid (process id) data
  576. type, put -DPID_T=pid_t or whatever in your CFLAGS.
  577.  
  578. If you get complaints about unknown data types uid_t and gid_t, put
  579. -DUID_T=xxx -DGID_T=yyy in your CFLAGS, where xxx and yyy are the appropriate
  580. types.
  581.  
  582. If you get complaints that getpwuid() is being called with an improper type,
  583. put -DPWID_T=xx in your CFLAGS.
  584.  
  585. If the compiler complains about the declaration of getpwnam() during an ANSI C
  586. compilation, remove the declaration from ckufio.c or change the argument in
  587. the prototype from (char *) to (const char *).
  588.  
  589. If you get compile-time warnings that t_brkc or t_eofc (tchars structure
  590. members, used in BSD-based versions) are undefined, or structure-member-
  591. related warnings that might be traced to this fact, add -DNOBRKC to CFLAGS.
  592.  
  593. If you get a linker message to the effect that _setreuid or _setregid is not
  594. defined, add -DNOSETREU to CFLAGS, or add -DCKTYP_H=<blah> to CFLAGS to make
  595. C-Kermit read the right <types.h>-kind-of-file to pick up these definitions.
  596.  
  597. If you get a message that _popen is undefined, add -DNOPOPEN to CFLAGS.
  598.  
  599. If you get a complaint at compile time about an illegal pointer-integer
  600. combination in ckufio.c involving popen(), or at link time that _popen is an
  601. undefined symbol, add the declaration "FILE *popen();" to the function zxcmd()
  602. in ckufio.c (this declaration is supposed to be in <stdio.h>).  If making this
  603. change does not help, then apparently your UNIX does not have the popen()
  604. function, so you should add -DNOPOPEN to your make entry, in which case
  605. certain functions involving "file" i/o to the standard input and output of
  606. subprocesses will not be available.
  607.  
  608. If your linker complains that _getcwd is undefined, you can add a getcwd()
  609. function to ckufio.c, or add it to your libc.a library using ar:
  610.  
  611. #include <stdio.h>
  612.  
  613. char *
  614. getcwd(buf,size) char *buf; int size; {
  615. #ifndef NOPOPEN
  616. #ifdef DCLPOPEN
  617.     FILE *popen();
  618. #endif
  619.     FILE *pfp;
  620.  
  621.     if (!buf) return(NULL);
  622.     if (!(pfp = popen("pwd","r"))) return(NULL);
  623.     fgets(buf,size-2,pfp);
  624.     pclose(pfp);
  625.     buf[strlen(buf)-1] = '\0';
  626.     return((char *)buf);
  627. #else
  628.     buf[0] = '\0';
  629.     return(NULL);
  630. #endif /* NOPOPEN */
  631. }
  632.  
  633. #ifdef NOPOPEN
  634. FILE *popen(s,t) char *s,*t; {
  635.     return(NULL);
  636. }
  637. #endif /* NOPOPEN */
  638.  
  639. If you get complaints about NPROC having an invalid value, add a valid
  640. definition for it (depends on your system), as in the cray entry.
  641.  
  642. If you get some symbol that's multiply defined, it probably means that a
  643. variable name used by Kermit is also used in one of your system libraries that
  644. Kermit is linked with.  For example, under PC/IX some library has a variable
  645. or function called "data", and the variable "data" is also used extensively by
  646. Kermit.  Rather than edit the Kermit source files, just put a -D in the make
  647. entry CFLAGS to change the Kermit symbol at compile time.  In this example, it
  648. might be -Ddata=datax.
  649.  
  650. Some symbol is defined in your system's header files, but it produces
  651. conflicts with, or undesired results from, Kermit.  Try undefining the symbol
  652. in the makefile entry's CFLAGS, for example -UFIONREAD.
  653.  
  654. Some well-known symbol is missing from your system header files.  Try defining
  655. in the makefile entry's CFLAGS, for example -DFREAD=1.
  656.  
  657. You get many warnings about pointer mismatches.  This probably means that
  658. Kermit is assuming an int type for signal() when it should be void, or
  659. vice-versa.  Try adding -DSIG_I (for integer signal()) or -DSIG_V (for void)
  660. to CFLAGS.  Or just include KFLAGS=-DSIG_V (or whatever) in your "make"
  661. command, for example:
  662.  
  663.   make bsd KFLAGS=-DSIG_V
  664.  
  665. You get many messages about variables that are declared and/or set but never
  666. used.  It is difficult to avoid these because of all the conditional
  667. compilation in the program.  Ignore these messages.
  668.  
  669. Some of C-Kermit's modules are so large, or contain so many character string
  670. constants, or are so offensive in some other way, that some C compilers give
  671. up and refuse to compile them.  This is usually because the -O (optimize)
  672. option is included in the make entry.  If this happens to you, you can
  673. (a) remove the -O option from the make entry, which will turn off the
  674. optimizer for ALL modules; (b) compile the offending module(s) by hand,
  675. including all the switches from make entry except for -O, and then give the
  676. appropriate "make" command again; or (c) increase the value of the -Olimit
  677. option, if your compiler supports this option.
  678.  
  679. As an extreme example, some compilers (e.g. gcc on the DG Aviion) have been
  680. known to dump core when trying to compile ckwart.c with optimization.  So just
  681. do this one "by hand":
  682.  
  683.    cc -o wart ckwart.c
  684.  
  685. and then give the "make" command again.
  686.  
  687. Speaking of wart, it is unavoidable that some picky compilers might generate
  688. "statement unreachable" messages when compiling ckcpro.c.  Unreachable
  689. statements can be generated by the wart program, which generates ckcpro.c
  690. automatically from ckcpro.w, which translates lex-like state/input
  691. constructions into a big switch/case construction.
  692.  
  693. Some function in Kermit wreaks havoc when it is called.  Change all
  694. invocations of the function into a macro that evaluates to the appropriate
  695. return code that would have been returned by the function had it been called
  696. and failed, for example: -Dzkself()=0.  Obviously not a good idea if the
  697. function is really needed.
  698.  
  699. If you have just installed SunOS 4.1.2 or 4.1.3, you might find that C-Kermit
  700. (and any other C program) fails to link because of unresolved references from
  701. within libc.  This is because of a mistake in Sun's /usr/lib/shlib.etc files
  702. for building the new libc.  Change the libc Makefile so that the "ld" lines
  703. have "-ldl" at the end.  Change the README file to say "mv xccs.multibyte.
  704. xccs.multibyte.o" and follow that instruction.
  705.  
  706. UNIX FILE SYSTEM PECULIARITIES
  707.  
  708. Normally, including a BSD, System-V, POSIX, or DIRENT flag in the make entry
  709. selects the right file system code.  But more recent versions of UNIX are
  710. inconsistent in this regard, and building in the normal way either gives
  711. compiler or linker errors, or results in problems at runtime, typically
  712. failure to properly expand wildcard file specifications when you do something
  713. like "send *.*", or failure to recognize long filenames, as in "send
  714. filewithaverylongname".
  715.  
  716. File creation dates: C-Kermit attempts to set the creation date/time of an
  717. incoming file according to the date/time given in the file's attribute
  718. packet, if any.  If you find that the dates are set incorrectly, you might
  719. need to build Kermit with the -DSYSUTIMEH flag, to tell it to include
  720. <sys/utime.h>.
  721.  
  722. C-Kermit is supposed to know about all the various styles of UNIX file
  723. systems, but it has to be told which one to use when you build it, usually in
  724. the makefile entry CFLAGS as shown below, but you might also have to add
  725. something like -I/usr/include/bsd to CFLAGS, or something like -lbsd to LIBS.
  726.  
  727. C-Kermit gives you the following CFLAGS switches to adapt to your file system's
  728. peculiarities:
  729.  
  730.   -DDIRENT   - #include <dirent.h>
  731.   -DSDIRENT  - #include <sys/dirent.h>
  732.   -DNDIR     - #include <ndir.h>
  733.   -DXNDIR    - #include <sys/ndir.h>
  734.   -DRTU      - #include "/usr/lib/ndir.h", only if NDIR and XNDIR not defined.
  735.   -DSYSUTIMH - #include <sys/utime.h> for setting file creation dates.
  736.   
  737. (Note, RTU should only be used for Masscomp RTU systems, because it also
  738. selects certain other RTU-specific features.)
  739.  
  740. If none of these is defined, then <sys/dir.h> is used, which is (currently)
  741. the most common case.  IMPORTANT: If your system has the file
  742. /usr/include/dirent.h then be sure to add -DDIRENT to your makefile entry's
  743. CFLAGS.  "dirent" should be used in preference to any of the others, because
  744. it supports all the features of your file system, and the others probably
  745. don't.
  746.  
  747. Having selected the appropriate directory header file, you might also need to
  748. tell Kermit how to declare the routines and variables it needs to read the
  749. directory.  This happens most commonly on AT&T System-V based UNIXes,
  750. particularly System V R3 and earlier, that provide long file and directory
  751. names (longer than 14 characters).  Examples include certain releases of
  752. HP-UX, DIAB DNIX, older versions of Silicon Graphics IRIX, and perhaps also
  753. MIPS.  In this case, try adding -DLONGFN to your makefile entry.  For further
  754. details, see the discussion under edit 5A(149) in the program update history,
  755. ckuker.upd.
  756.  
  757. Another problem child is <sys/file.h>.  Most UNIX C-Kermit versions need to
  758. #include this file from within ckutio.c and ckufio.c, but some not only do not
  759. need to include it, but MUST not include it because (a) it doesn't exist, or
  760. (b) it has already been included by some other header file and it doesn't
  761. protect itself against multiple inclusion, or (c) some other reason that
  762. prevents successful compilation.  If you have compilation problems that seem
  763. to stem from including this file, then add the following switch to CFLAGS in
  764. your makefile entry:
  765.  
  766.   -DNOFILEH
  767.  
  768. There are a few odd cases where <sys/file.h> must be included in one of the
  769. cku[ft]io.c files, but not the other.  In that case, add the aforementioned
  770. switch, but go into the file that needs <sys/file.h> and add something like
  771. this:
  772.  
  773.   #ifdef XXX       /* (where XXX is a symbol unique to your system) */
  774.   #undef NOFILEH
  775.   #endif /* XXX */
  776.  
  777. before the section that includes <sys/file.h>.
  778.  
  779. Kermit's SEND command expands wildcard characters "?" and "*" itself.  Before
  780. version 5A, commands like "send *" would send all regular (non-directory)
  781. files, including "hidden files" (whose names start with ".").  In version 5A,
  782. the default behavior is to match like the Bourne shell or the ls command, and
  783. not include files whose names start with dot.  Such files can still be sent if
  784. the dot is included explicitly in the SEND command: "send .oofa, send .*".  To
  785. change back to the old way and let leading wildcard characters match dot
  786. files, include the following in your CFLAGS:
  787.  
  788.   -DMATCHDOT
  789.  
  790. If you get compile-time complaints about data type mismatches for process-ID
  791. related functions like getpid(), add -DPID_T=pid_t.
  792.  
  793. If you get compile-time complaints about data type mismatches for user ID
  794. related functions like getuid(), add -DUID_T=uid_t.
  795.  
  796. If you get compile-time complaints about data type mismatches for user-ID
  797. related functions like getgid(), add -DGID_T=gid_t.
  798.  
  799. If you get compile-time complaints about data type mismatches for getpwuid(),
  800. add -DPWID_T=uid_t (or whatever it should be).
  801.  
  802.  
  803. HARDWARE FLOW CONTROL
  804.  
  805. Hardware flow control is, in general, a problematic concept in many popular
  806. UNIX implementations.  Often it is lacking altogether, and when available,
  807. the application program interface (API) to it is inconsistent from system to
  808. system.  Here are some examples:
  809.  
  810. 1. POSIX does not support hardware flow control.
  811.  
  812. 2. RTS/CTS flow control support MIGHT be available for System V R3 and later
  813.    if /usr/include/termiox.h exists (its successful operation also depends on
  814.    the device driver, and the device itself, not to mention the cable, etc,
  815.    actually supporting it).  If your SVR3-or-later UNIX system does have this
  816.    file, add:
  817.  
  818.      -DTERMIOX
  819.  
  820.    to your CFLAGS.  If the file is in /usr/include/sys instead, add:
  821.  
  822.      -DSTERMIOX
  823.  
  824.    Note that the presence of this file does not guarantee that RTS/CTS will
  825.    actually work -- that depends on the device-driver implementation
  826.    (reportedly, many UNIX versions treat hardware-flow-control related ioctl's
  827.    as no-ops).
  828.  
  829. 3. Search (grep) through /usr/include/*.h and /usr/include/sys/*.h for
  830.    RTS or CTS and see what turns up.  For example, in SunOS 4.x we find
  831.    "CRTSCTS".  Figuring out how to use it is another question entirely!
  832.    In IBM AIX RS/6000, we have to "add" a new "line discipline" (and you
  833.    won't find uppercase RTS or CTS symbols in the header files).
  834.  
  835. 4. NeXTSTEP supports hardware flow control, but does not furnish an API to
  836.    control it, and thus NeXTSTEP Kermit has no command to select it --
  837.    instead, a special device name must be used.
  838.  
  839. 5. RTS/CTS is available in Linux, but you have to place a line like:
  840.  
  841.      stty crtscts < /dev/modem
  842.  
  843.    in your /etc/rc.local file (where /dev/modem is the device name of
  844.    any serial device that you want to have RTS/CTS flow control enabled).
  845.  
  846. See the routine tthflow() in ckutio.c for details.  If you find that your
  847. system offers hardware flow control selection under program control, you can
  848. add this capability to C-Kermit as follows:
  849.  
  850.  1. See if it agrees with one of the methods already used in tthflow().
  851.     If not, add new code, appropriately #ifdef'd.
  852.  
  853.  2. Add -DCK_RTSCTS to the compiler CFLAGS in your makefile entry or define
  854.     this symbol within the appropriate #ifdef's in ckcdeb.h.
  855.  
  856. To illustrate the difficulties with RTS/CTS, here is a tale from Jamie Watson
  857. <jw@adasoft.ch>, who added the RTS/CTS code for the RS/6000, about his
  858. attempts to do the same for DEC ULTRIX:
  859.  
  860.    "The number and type of hardware signals available to/from a serial port
  861.    vary between different machines and different types of serial interfaces on
  862.    each machine.  This means that, for example, there are virtually no
  863.    hardware signals in or out available on the DECsystem 3000/3100 series; on
  864.    the DECsystem 5000/2xx series all modem signals in/out are present on both
  865.    built-in serial ports; on the DECsystem 5100 some ports have all signals
  866.    and some only have some; and so on...  It looks to me as if this pretty
  867.    well rules out any attempt to use hardware flow control on these platforms,
  868.    even if we could figure out how to do it.  The confusion on the user level
  869.    about whether or not it should work for any given platform or port would be
  870.    tremendous.  And then it isn't clear how to use the hardware signals even
  871.    in the cases where the device supports them."
  872.  
  873.  
  874. OTHER SYSTEM-DEPENDENT FEATURES
  875.  
  876. There is no standard for millisecond sleeps, but at least three different
  877. functions have appeared in various UNIX versions that can be used for this
  878. purpose: nap() (mostly in System V), usleep() (found at least in SunOS and
  879. NeXT OS), and select() (found in 4.2BSD and later).  If you have any of these
  880. available, pick one:
  881.  
  882.   -DNAP:    Include this in CFLAGS if your system has the nap() function.
  883.   -DSELECT: Include this in CFLAGS if your system has the select() function.
  884.   -USLEEP:  Include this in CFLAGS if your system has the usleep() function.
  885.  
  886. NOTE: The nap() function is assumed to be a function that puts the process
  887. to sleep for the given number of milliseconds.  If your system's nap()
  888. function does something else or uses some other units of time (like the NCR
  889. Tower 32, which uses clock-ticks), do not include -DNAP.
  890.  
  891. Reportedly, all versions of System V R4 for Intel-based computers, and
  892. possibly also SVR3.2, include nap() as a kernel call, but it's not in the
  893. library.  To include code to use it via syscall(3112,x), without having to
  894. include Xenix compatibility features, include the following compile-time
  895. option:
  896.  
  897.   -DNAPHACK
  898.  
  899. Many AT&T UNIX versions have no way to check if input is waiting on a tty
  900. device.  This is a very important feature for Kermit.  Without it, sliding
  901. windows might not work very well (or at all), and you also have to type your
  902. escape character to get Kermit's attention in order to interrupt a local-mode
  903. file transfer.  However, certain System-V variations, mostly those from SCO,
  904. include a rdchk() function.  If your version of UNIX had rdchk(), include:
  905.  
  906.   -DRDCHK:  Include this in CFLAGS if your system has the rdchk() function.
  907.  
  908. Otherwise, if your version of UNIX has the poll() function (and the
  909. /usr/include/poll.h file), include:
  910.  
  911.   -DCK_POLL
  912.  
  913. Systems with <termios.h> might have the symbol IEXTEN defined.  This is used
  914. to turn ^V/^O processing on and off.  It should be turned off during Kermit
  915. operation, so if ckutio.c finds this symbol, it uses it.  This is necessary,
  916. at least, on BSDI.  On some systems, however, IEXTEN is either misdefined or
  917. misimplemented.  The symptom is that CR, when typed to the command processor,
  918. is echoed as LF, rather than CRLF.  This happens (at least) on Convex/OS 9.1.
  919. The solution is to add the following symbol to the makefile entry's CFLACS:
  920.  
  921.   -DNOIEXTEN
  922.  
  923. In edits 177 and earlier, workstation users noticed a "slow screen writing"
  924. phenomenon during interactive command parsing.  This was traced to a setbuf()
  925. call in ckutio.c that made console (stdout) writes unbuffered.  This setbuf()
  926. call has been there forever, and probably can't be removed without some risk.
  927. Kermit's operation was tested on the NeXT in edit 178 with the setbuf() call
  928. removed, and the slow-writing symptom was cured, and everything else (command
  929. parsing, proper wakeup on ?, ESC, Ctrl-U, and other editing characters,
  930. terminal emulation, remote-mode and local-mode file transfer, etc) seemed to
  931. work as well as or better than before.  To remove the setbuf() call for your
  932. version of Kermit, add:
  933.  
  934.   -DNOSETBUF
  935.  
  936. Later reports indicate that adding -DNOSETBUF has other beneficial effects,
  937. like cutting down on swapping when Kermit is run on workstations with small
  938. memories.  But BEWARE: on certain small UNIX systems, notably the AT&T 6300
  939. and 3B1 (the very same ones that benefit from NOSETBUF), NOSETBUF seems to
  940. conflict with CK_CURSES.  The program builds and runs OK, but after once using
  941. the curses display, echoing is messed up.  In this case, we use a System-V
  942. specific variation in the curses code, using newterm() to prevent System V
  943. from altering the buffering.  See makefile entries for AT&T 6300 and 3B1.
  944.  
  945. The UNIX version of C-Kermit includes code to switch to file descriptor zero
  946. (stdin) for remote-mode file transfer.  This code is necessary to prevent
  947. Kermit from giving the impression that it is "idle" during file transfers,
  948. which, at some sites, can result in the job being logged out by idle-job
  949. watchers.  However, this feature can interfere with certain setups; for
  950. example, there is a package which substitutes a pty/tty pair for /dev/tty and
  951. sets file descriptor 0 to be read-only, preventing Kermit from sending
  952. packets.  To remove this feature and allow Kermit to work in such
  953. environments, add the compile-time option:
  954.  
  955.   -DNOFDZERO
  956.  
  957. Some versions of UNIX render a tty device unusable after a hangup operation.
  958. Examples include IBM AIX on the RT PC and RS/6000.  A typical symptom of this
  959. phenomenon is that the DIAL command doesn't work, but CONNECTing to the device
  960. and dialing manually do work.  A further test is to SET DIAL HANGUP OFF, which
  961. should make dialing work once by skipping the pre-dial hangup.  However, after
  962. the connection is broken, it can't be used any more: subsequent attempts to
  963. DIAL the same device won't work.  The cure is usually to close and reopen the
  964. device as part of the hangup operation.  To do this, include the following
  965. compile-time option:
  966.  
  967.   -DCLSOPN
  968.  
  969. Similarly, there is a section of code in ttopen(), which does another
  970. close(open()) to force the O_NDELAY mode change.  On some systems, the
  971. close(open()) is required to make the mode change take effect, and apparently
  972. on most others it does no harm.  But reportedly on at least one System V R4
  973. implementation, and on SCO Xenix 3.2, the close(open()) operation hangs
  974. if the device lacks carrier, EVEN THOUGH the CLOCAL characteristic has just
  975. been set to avoid this very problem.  If this happens to you, add this to
  976. your CFLAGS:
  977.  
  978.   -DNOCOTFMC
  979.  
  980. or, equivalently, in your KFLAGS on the make command line.  It stands for
  981. NO Close(Open()) To Force Mode Change.
  982.  
  983. C-Kermit renames files when you give a RENAME command and also according to
  984. the current SET FILE COLLISION option when receiving files.  The normal UNIX
  985. way to rename a file is via two system calls: link() and unlink().  But
  986. this leaves open a window of vulnerability.  Some UNIX systems also offer an
  987. atomic rename(oldname,newname) function.  If your version of UNIX has this
  988. function, add the following to your CFLAGS:
  989.  
  990.   -DRENAME
  991.  
  992. C-Kermit predefines the RENAME for several UNIX versions in ckcdeb.h (SVR4,
  993. SUNOS41, BSD44, AIXRS, etc).  You can tell if rename() is being used if the
  994. SHOW FEATURES command includes RENAME in the compiler options list.  If the
  995. predefined RENAME symbol causes trouble, then add NORENAME to your CFLAGS.
  996.  
  997. Finally, here's a switch you should NEVER set:
  998.  
  999.   -DCOMMENT
  1000.  
  1001. It's used for commenting out blocks of code.  If for some reason you find
  1002. that your compiler has COMMENT defined, then add -UCOMMENT to CFLAGS!
  1003.  
  1004. TERMINAL INTERRUPTION
  1005.  
  1006. When C-Kermit enters interactive command mode, it sets a Control-C (terminal
  1007. keyboard interrupt = SIGINT) trap to allow it to return to the command prompt
  1008. whenever the user types Control-C (or whatever is assigned to be the interrupt
  1009. character).  This is implemented using setjmp() and longjmp().  On some
  1010. systems, depending on the machine architecture and C compiler, you might get
  1011. "Memory fault (coredump)" or "longjmp botch" instead of the desired effect.
  1012. In that case, add -DNOCCTRAP to your CFLAGS and rebuild the program.
  1013.  
  1014. Job control -- the ability to "suspend" C-Kermit on a UNIX system by typing
  1015. the "susp" character (normally Ctrl-Z) and then resume execution later (with
  1016. the "fg" command) -- is a tricky business.  C-Kermit must trap suspend signals
  1017. so it can put the terminal back into normal mode when you suspend it (Kermit
  1018. puts the terminal into various strange modes during interactive command
  1019. parsing, CONNECT, and file transfer).  Supporting code is compiled into
  1020. C-Kermit automatically if <signal.h> includes a definition for the SIGTSTP
  1021. signal.  HOWEVER... some systems define this signal without supporting
  1022. job control correctly.  You can build Kermit to ignore SIGTSTP signals by
  1023. including the -DNOJC option in CFLAGS.  (You can also do this at runtime by
  1024. giving the command SET SUSPEND OFF.)
  1025.  
  1026. System V R3 and earlier systems normally do not support job control.  If you
  1027. have an SVR3 system that does, include the following option in your CFLAGS:
  1028.  
  1029. -DSVR3JC
  1030.  
  1031.  
  1032. DIALING OUT AND COORDINATING WITH UUCP
  1033.  
  1034. Make sure your dialout line is correctly configured for dialing out (as
  1035. opposed to login).  The method for doing this is different for each kind of
  1036. UNIX system.  Consult your system documentation for configuring lines for
  1037. dialing out (for example, SUN SparcStation IPC users should read the section
  1038. "Setting up Modem Software" in the Desktop SPARC Sun System & Network
  1039. Manager's Guide).
  1040.  
  1041. Unlike other operating systems, UNIX allows multiple processes to access the
  1042. same tty device at the same time, even though there is no earthly reason why
  1043. two processes would want to do this.  When they do, process A will read some
  1044. of the incoming characters, and process B will read the others.  Neither
  1045. process will see them all.  As you can imagine, this can cause enormous
  1046. difficulties for any communication program.
  1047.  
  1048. Rather than change UNIX to make exclusive access to tty devices be the
  1049. default, UNIX vendors hit upon the idea of a "lock file".  Any process that
  1050. wants to open a tty device should first check and see if a file of a certain
  1051. name exists, and if so, not to open the device.  If the file does not exist,
  1052. the process creates the file and then opens the device.  When the process
  1053. closes the device, it destroys the lockfile.  This procedure was originated
  1054. for use with UNIX's UUCP, CU, and TIP programs, and so these lockfiles are
  1055. commonly called "UUCP lockfiles" (UUCP = UNIX-to-UNIX Copy Program).
  1056.  
  1057. As you can imagine, this method is riddled with pitfalls:
  1058.  
  1059.   - If a process does not observe the lockfile convention (or the SAME
  1060.     lockfile convention), then it can interfere with other "polite"
  1061.     processes.
  1062.  
  1063.   - If a process crashes while it has the device open, the lockfile is
  1064.     left behind, preventing further processes from using the device.
  1065.  
  1066.   - Various versions of UNIX use different names for the lockfiles, put
  1067.     them in different directories, and specify their contents differently.
  1068.  
  1069.   - On a given system, the lockfile conventions may change from one UNIX 
  1070.     release to the next (for example, SUNOS 4.0 to 4.1).
  1071.  
  1072.   - The same tty device might have more than one name, and many lockfile
  1073.     conventions don't allow for this.
  1074.  
  1075. In order to fit in with UUCP and other UNIX-based communication software,
  1076. C-Kermit must have the same idea as your system's uucp, cu, and tip programs
  1077. about what the UUCP lock directory is called, what the lockfile itself is
  1078. called, and what its contents should be.  In most cases, Kermit tries to
  1079. figure this out automatically (see ckutio.c).  The following CFLAGS options
  1080. can be used to override C-Kermit's normal assumptions:
  1081.  
  1082.   -DLCKDIR:   Tells Kermit that the UUCP lock directory is /usr/spool/uucp/LCK.
  1083.  
  1084.   -DACUCNTRL: Tells Kermit to use the BSD 4.3 acucntrl() program to turn
  1085.               off getty (login) on the line before using it, and restore
  1086.               getty when done.
  1087.  
  1088.   -DHDBUUCP:  Include this if your system uses Honey DanBer UUCP.
  1089.  
  1090.   -DLOCK_DIR=\\\"/xxx/yyy\\\": Gives the lock directory name explicitly.
  1091.               The triple quoting is necessary.  For example: 
  1092.               "CFLAGS= -DBSD4 -DLOCK_DIR=\\\"/usr/local/locks\\\" -DNODEBUG"
  1093.  
  1094.   -DLFDEVNO   The lockfile name uses the tty device inode and major and minor
  1095.               numbers: LK.dev.maj.min, as in Sys V R4, e.g. LK.035.044.008.
  1096.  
  1097. Honey DanBer (HDB) UUCP, which is becoming increasingly popular, has two  
  1098. characteristics:
  1099.  
  1100.    a. Lockfiles are kept in /usr/spool/locks/.
  1101.    b. A lockfile contains the process id (pid) in ASCII, rather than as an int.
  1102.  
  1103. All non-HDB selections assume the lockfile contains the pid in int form (or,
  1104. more precisely, in PID_T form, where PID_T is either int or pid_t, depending
  1105. on your system's C library and header files).
  1106.  
  1107. Even if you build the program with the right lockfile option, you can still
  1108. have problems when you try to open the device.  Here are the error messages
  1109. you can get from SET LINE, and what they mean:
  1110.  
  1111.    a. "Timed out, no carrier."  This one is not related to lockfiles.  It
  1112.       means that you have SET CARRIER ON xx, where xx is the number of seconds
  1113.       to wait for carrier, and carrier did not appear within xx seconds.
  1114.       Solution: SET CARRIER AUTO or OFF.
  1115.  
  1116.    b. "Sorry, access to lock denied."  Kermit has been configured to use
  1117.       lockfiles, but (a) the lockfile directory is write-protected against
  1118.       you, or (b) it does not exist.  The "access to lock denied" message will
  1119.       tell you the reason.  If the lockfile does not exist, check to make sure
  1120.       Kermit is using the right name.  Certain recent releases of UNIX have
  1121.       changed the location of the lockfile from /usr/spool/whatever to
  1122.       /var/spool/whatever.  In this case, ask the system manager install a
  1123.       symbolic link from the old name to the new name.
  1124.       Other solutions: (see below)
  1125.  
  1126.    c. "Sorry, access to tty device denied."  The tty device that you specified
  1127.       in your SET LINE command is read/write protected against you.
  1128.       Solution: (see below)
  1129.  
  1130.    d. "Sorry, device is in use."  The tty device you have specified is
  1131.       currently being used by another user.  A prefatory message gives you
  1132.       an "ls -l" listing of the lockfile, which should show the username of
  1133.       the person who created it, plus a message "pid = nnn" to show you the
  1134.       process id of the user's program.  Solutions: try another device,
  1135.       wait until the other user is finished, ask the other user to hurry up,
  1136.       or ask the system manager for help.
  1137.  
  1138.    e. "Sorry, can't open connection: <reason>".  The device cannot be opened
  1139.       for some other reason, which is listed.
  1140.  
  1141.    f. "sh: /usr/lib/uucp/acucntrl: not found".  This means your Kermit program
  1142.       was built with the -DACUCNTRL switch, but your computer system does not
  1143.       have the BSD 4.3 acucntrl program.  Solution: install the acucntrl
  1144.       program if you have it, or rebuild Kermit without the -DACUCNTRL switch.
  1145.  
  1146. There are two solutions for problems (b) and (c), both of which involve
  1147. intervention by the manager (superuser) of your UNIX system:
  1148.  
  1149.    a. Have the superuser change the permission of the lockfile directory and
  1150.       to the tty devices so that everyone on the system has read/write
  1151.       permission.
  1152.  
  1153.         su% chmod 777 /usr/spool/locks (or whatever the path is)
  1154.         su% chmod 666 /dev/ttyXX
  1155.  
  1156.       The risk here is that people can write lots of junk into the lockfile
  1157.       directory, delete other people's files in the lockfile directory, and
  1158.       intercept other people's data as it goes in and out of the tty device.
  1159.       The major danger here would be intercepting a privileged password.  Of
  1160.       course, any user could write a short, ordinary, unprivileged program to
  1161.       do exactly the same thing!
  1162.  
  1163.    b. Have the superuser change Kermit to run setuid or setgid to the owner of
  1164.       the lockfile directory (and the tty devices if necessary), typically
  1165.       uucp (see next section).
  1166.  
  1167.     su% chown uucp kermit
  1168.     su% chmod u+s kermit (setuid)  - or -  chmod g+s kermit (setgid)
  1169.  
  1170.       and then make sure the lockfile directory, and the tty devices, have
  1171.       owner (setuid) and/or group (setgid) write permission.  For example:
  1172.  
  1173.         su% chmod o+rwx /usr/spool/uucp
  1174.         su% chown uucp /dev/ttyXX ; chmod 600 /dev/ttyXX
  1175.  
  1176.       On the whole, the setuid option should be avoided whenever possible,
  1177.       because any loophole in this enormously complicated program could be
  1178.       exploited to grant the user the privileges of the user to whom the
  1179.       program is setuid'd or setgid'd to.
  1180.  
  1181. For the lockfile mechanism to achieve its desired purpose -- prevention of
  1182. access to the same tty device by more than one process at a time -- ALL
  1183. programs on a given computer that open, read or write, and close tty devices
  1184. must use the SAME lockfile conventions.  Unfortunately, this is often not the
  1185. case.  Here is a typical example of how this can go wrong: In SunOS 4.0 and
  1186. earler, the lockfile directory was /usr/spool/uucp; in 4.1 it was changed to
  1187. /var/spool/locks.  Therefore, any programs that were not modified to account
  1188. for this change, recompiled, and reinstalled, will not be using the same
  1189. lockfiles as uucp, tip, etc, and so the entire purpose of the lockfile is
  1190. defeated.
  1191.  
  1192. What if your UNIX system does not have UUCP installed?  For example, you have
  1193. a UNIX workstation, and you do not use uucp, cu, or tip, or UUCP was not even
  1194. supplied with your version of UNIX.  In this case, you have two choices:
  1195.  
  1196.    a. If there may be more than one person running Kermit at the same time,
  1197.       competing for the same tty device, then create a special lockfile
  1198.       directory just for Kermit, for example, /usr/spool/kermit, and make sure
  1199.       you have read/write access to it.  Then add the following to your
  1200.       makefile entry CFLAGS, as shown earlier:
  1201.  
  1202.            -DLOCK_DIR=\\\"/usr/spool/kermit\\\"
  1203.  
  1204.    b. If you are the only user on your workstation, and no other processes will
  1205.       ever be competing with Kermit for the dialout tty device, then add 
  1206.       -DNOUUCP to your makefile entry's CFLAGS and rebuild Kermit.
  1207.  
  1208.  
  1209. RUNNING UNIX C-KERMIT SETUID OR SETGID
  1210.  
  1211. Even if you don't intend to run C-Kermit setuid, somebody else might come
  1212. along and chown and chmod it after it has been built.  You should be sure
  1213. that it is built correctly to run setuid on your system.  For AT&T UNIX
  1214. versions, you don't have to do anything special.
  1215.  
  1216. For BSD-based UNIX versions, 4.2 and later, you normally need not add anything
  1217. special to the makefile.  The program assumes that the setreuid() and
  1218. setregid() functions are available, without which we cannot switch back &
  1219. forth between real & effective uids.  If "make" complains that _setreuid or
  1220. _setregid is/are not defined, add -DNOSETREU to CFLAGS.  In this case it is
  1221. very likely (but not certain) that you cannot protect ttys and lockfiles
  1222. against people and have them run Kermit setuid.
  1223.  
  1224. If make does not complain about this, you should find out whether your BSD
  1225. version (4.3 or later, or other systems like SunOS 4.x that claim to include
  1226. BSD 4.3 compatibility) includes the saved-setuid feature (see long notes under
  1227. edit 146 in ckuker.upd).  If it does, then add -DSAVEDUID to CFLAGS.
  1228.  
  1229.   IMPORTANT NOTE: Most UNIX system documentation will not give you the
  1230.   required information.  To determine whether your UNIX system supplies the
  1231.   the saved-original-effective-user/group-id feature, use the ckuuid.c
  1232.   program.  Read and follow the instructions in the comments at the beginning.
  1233.  
  1234. If you have a version of UNIX that is not BSD-based, but which supplies the
  1235. setreuid() and setregid() functions, and these are the only way to switch
  1236. between real and effective uid, add -DSETREUID to your makefile entry.
  1237.  
  1238.   WARNING: There are two calls to access() in ckufio.c, by which Kermit checks
  1239.   to see if it can create an output file.  These calls will not work correctly
  1240.   when (a) you have installed C-Kermit setuid or setgid on a BSD-based UNIX
  1241.   system; (b) the saved-original-effective-uid/gid feature is not present; and
  1242.   (c) the access() function always checks what it believes to be the real ID
  1243.   rather than the effective ID.  This is the case, for example, in Olivetti
  1244.   X/OS and in NeXTSTEP.  In such cases, you can force correct operation of
  1245.   access() calls by including defining the symbol SW_ACC_ID at compile time in
  1246.   the CFLAGS.
  1247.  
  1248. If you have a version of UNIX that does not allow a process to switch back and
  1249. forth between its effective and real user and group ids multiple times, you
  1250. probably should not attempt to run Kermit setuid, because once having given up
  1251. its effective uid or gid (which it must do in order to transfer files, fork a
  1252. shell, etc) it can never get it back, and so it can not use the original
  1253. effective uid or gid to create or delete uucp lockfiles.  In this case, you'll
  1254. either have to set the permissions on your lockfile directory to make them
  1255. publicly read/writable, or dispense with locking altogether.
  1256.  
  1257. CONFIGURING UNIX WORKSTATIONS
  1258.  
  1259. On desktop workstations that are used by only the user at the console
  1260. keyboard, C-Kermit is always used in local mode.  But as delivered, C-Kermit
  1261. runs in remote mode by default.  To put it in local mode at startup, you can
  1262. put a SET LINE command in your .kermrc.
  1263.  
  1264. You can also build C-Kermit to start up in local mode by default.  To do this,
  1265. include the following in the CFLAGS in your makefile entry:
  1266.  
  1267. -DDFTTY=\\\"/dev/ttyxx\\\"
  1268.  
  1269. where ttyxx is the name of the device you will be using for communications.
  1270. Presently there is no way of setting the default modem type at compile time,
  1271. so use this option only for direct lines.
  1272.  
  1273. C-Kermit does not work well on certain workstations if it is not run from
  1274. within a terminal window.  For example, you cannot start C-Kermit on a NeXT by
  1275. launching it directly from NeXTstep.  Similarly for SUN workstations in the
  1276. Open Windows environment.  Run Kermit in a terminal window.
  1277.  
  1278. BIZARRE BEHAVIOR AT RUNTIME
  1279.  
  1280. See the beware file, ckuker.bwr, for hints about runtime misbehavior.
  1281. This section lists some runtime problems that can be cured by rebuilding
  1282. C-Kermit.
  1283.  
  1284. The program starts, but there is no prompt, and certain operations don't work
  1285. (you see error messages like "Kermit command error in background execution").
  1286. This is because Kermit thinks it is running in the background.  See conbgt()
  1287. in ckutio.c.  Try rebuilding Kermit with:
  1288.  
  1289.  -DPID_T=pid_t
  1290.  
  1291. added to your CFLAGS.  If that doesn't help, find out the actual data type
  1292. for pids (look in types.h or similar file) and use it in place of "pid_t", 
  1293. for example:
  1294.  
  1295.  -DPID_T=short
  1296.  
  1297. Unexplainable and inappropriate error messages ("Sockets not supported on this
  1298. device", etc) have been traced in at least one case to a lack of agreement
  1299. between the system header files and the actual kernel.  This happened because
  1300. the GNU C compiler (gcc) was being used.  gcc wants to have ANSI-C-compliant
  1301. header files, and so part of the installation procedure for gcc is to run a
  1302. shell script called "fixincludes", which translates the system's header files
  1303. into a separate set of headers that gcc likes.  So far so good.  Later, a new
  1304. version of the operating system is installed and nobody remembers to run
  1305. fixincludes again.  From that point, any program compiled with gcc that makes
  1306. use of header files (particularly ioctl.h) is very likely to misbehave.
  1307. Solution: run fixincludes again, or use your system's regular C compiler,
  1308. libraries, and header files instead of gcc.
  1309.  
  1310. CRASHES AND CORE DUMPS
  1311.  
  1312. Total failure of the Kermit program can occur because of bad memory
  1313. references, bad system calls, or problems with dynamic memory allocation.
  1314. First, try to reproduce the problem with debugging turned on: run Kermit
  1315. with the -d command-line option (for example, "wermit -d") and then examine
  1316. the resulting debug.log file.  The last entry should be in the vicinity of
  1317. the crash.  In VAX/VMS, a crash automatically produces a "stack dump" which
  1318. shows the routine where the crash occurs.  In UNIX, you can get a stack dump
  1319. with "adb" -- just type "adb wermit core" and then give the command "$c",
  1320. then Ctrl-D to quit.
  1321.  
  1322. In edit 186, one implementation, UNISYS 5000/95 built with "make sys5r3", has
  1323. been reported to run out of memory very quickly (e.g. while executing a short
  1324. initialization file that contains a SET DIAL DIRECTORY command).  Debug logs
  1325. show that malloc calls are failing, reason unknown.  For this and any other
  1326. implementation that gives error messages about "malloc failure" or "memory
  1327. allocation failure", rebuild the program *without* the -DDYNAMIC CFLAGS
  1328. definition, for example:
  1329.  
  1330.   make sys5r3 KFLAGS=-UDYNAMIC
  1331.  
  1332. As of edit 169, C-Kermit includes a malloc() debugging package which you may
  1333. link with the Kermit program to catch runtime malloc errors.  See the makefile
  1334. entries for sunos41md and nextmd for examples of how to select malloc
  1335. debugging.  Once you have linked Kermit with the malloc debugger, it will halt
  1336. with an informative message if a malloc-related error occurs and, if possible,
  1337. dump core.  For this reason, malloc-debugging versions of Kermit should be
  1338. built without the "-s" link option (which removes symbols, preventing analysis
  1339. of the core dump).  You have several ways to track down the malloc error:
  1340. reproduce the problem with "log debug" and then look at the code around the
  1341. last debug.log entry.  Or run the program under gdb.  Or analyze the core dump
  1342. with adb.
  1343.  
  1344. (End of CKUINS.DOC)
  1345.